<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core">


    <ui:composition template="/WEB-INF/faces/template.xhtml">

        <!-- new title -->
        <ui:define name="title">
            <h:outputText value="Sunshine Hotel" />
        </ui:define>

        <!-- new content -->
        <ui:define name="content">

            <!-- Check login -->
            <ui:include src="/resources/include/checkLogin.xhtml" />

            <h1>
                Available rooms
            </h1>

            <p:panel>
                <h:form>            
                    <p:dataTable id="rooms" value="#{bookingControllerBean.freeRooms}" var="room">

                        <p:column sortBy="#{room.roomNb}" >
                            <f:facet name="header">
                                <h:outputText value="Room Number" />
                            </f:facet>
                            <h:outputText value="#{room.roomNb}" />
                        </p:column>

                        <p:column sortBy="#{room.bathRoom}" >
                            <f:facet name="header">
                                <h:outputText value="Bath Room" />
                            </f:facet>
                            <h:outputText value="#{room.bathRoom}" />
                        </p:column>

                        <p:column sortBy="#{room.kitchen}" >
                            <f:facet name="header">
                                <h:outputText value="Kitchen" />
                            </f:facet>
                            <h:outputText value="#{room.kitchen}" />
                        </p:column>
                        
                        <p:column sortBy="#{room.roomType}" >
                            <f:facet name="header">
                                <h:outputText value="RoomType" />
                            </f:facet>
                            <h:outputText value="#{room.roomType}" />
                        </p:column>
                        
                        <p:column sortBy="#{room.price}" >
                            <f:facet name="header">
                                <h:outputText value="Price" />
                            </f:facet>
                            <h:outputText value="#{room.price}" />
                        </p:column>
                        
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Book" />
                            </f:facet>
                            <h:commandButton value="Book" action="#{pickRoomControllerBean.add(room.id)}" />
                        </p:column>

                    </p:dataTable>
                </h:form>
            </p:panel>

        </ui:define>
    </ui:composition>
</html>